<link rel="stylesheet" href="<?php echo TEMPLATE_SITE_PATH; ?>css/datepicker.css" />
<script src="<?php echo TEMPLATE_SITE_PATH; ?>js/date-time/bootstrap-datepicker.min.js"></script>

<?php echo form_open_multipart('', 'class="form-horizontal" role="form"');?>
	<div class="form-group">
		<label class="col-sm-3 control-label no-padding-right">Title <span class="red"> *</span></label>
		<div class="col-sm-9">
			<?php echo form_input('title', set_value('title'), 'autocomplete="off" class="col-xs-10 col-sm-5"'); ?>
			<?php echo form_error('title', '<div class="col-sm-12 no-padding red">', '</div>'); ?>
		</div>
	</div>
	<div class="space-4"></div>
	<div class="form-group">
		<label class="col-sm-3 control-label no-padding-right">Price <span class="red"> *</span></label>
		<div class="col-sm-9">
			<?php echo form_input('price', set_value('price'), 'autocomplete="off" class="col-xs-10 col-sm-5"'); ?>
			<?php echo form_error('price', '<div class="col-sm-12 no-padding red">', '</div>'); ?>
		</div>
	</div>
	<div class="space-4"></div>
	<div class="form-group">
		<label class="col-sm-3 control-label no-padding-right">Category <span class="red"> *</span></label>
		<div class="col-sm-9">
			<?php echo form_dropdown('categoryId', $category, set_value('categoryId'), 'class="col-xs-10 col-sm-5"'); ?>
			<?php echo form_error('categoryId', '<div class="col-sm-12 no-padding red">', '</div>'); ?>
		</div>
	</div>
	<div class="space-4"></div>
	<div class="form-group">
		<label class="col-sm-3 control-label no-padding-right">Type <span class="red"> *</span></label>
		<div class="col-sm-9">
			<?php echo form_dropdown('typeId', $type, set_value('typeId'), 'class="col-xs-10 col-sm-5"'); ?>
			<?php echo form_error('typeId', '<div class="col-sm-12 no-padding red">', '</div>'); ?>
		</div>
	</div>
	<div class="space-4"></div>
	<div class="form-group">
		<label class="col-sm-3 control-label no-padding-right">Location <span class="red"> *</span></label>
		<div class="col-sm-9">
			<?php echo form_dropdown('locationId', $location, set_value('locationId'), 'class="col-xs-10 col-sm-5"'); ?>
			<?php echo form_error('locationId', '<div class="col-sm-12 no-padding red">', '</div>'); ?>
		</div>
	</div>
  <div class="space-4"></div>
  <div class="form-group">
      <label class="col-sm-3 control-label no-padding-right">Publish Date <span class="red"> *</span></label>
      <div class="col-sm-9">
          <?php echo form_input('publishDate', set_value('publishDate'), 'autocomplete="off" class="col-xs-10 col-sm-5 date-picker" data-date-format="dd-mm-yyyy"'); ?>
          <?php echo form_error('publishDate', '<div class="col-sm-12 no-padding red">', '</div>'); ?>
      </div>
  </div>
	<div class="space-4"></div>
	<div class="form-group">
		<label class="col-sm-3 control-label no-padding-right">Short Description <span class="red"> *</span></label>
		<div class="col-sm-9">
			<?php echo form_textarea('shortDescription', set_value('shortDescription'), 'autocomplete="off" class="col-xs-10 col-sm-9"'); ?>
			<?php echo form_error('shortDescription', '<div class="col-sm-12 no-padding red">', '</div>'); ?>
		</div>
	</div>
	<div class="space-4"></div>
	<div class="form-group">
		<label class="col-sm-3 control-label no-padding-right">Description <span class="red"> *</span></label>
		<div class="col-sm-9">
			<?php echo form_textarea('description', set_value('description'), 'autocomplete="off" class="col-xs-10 col-sm-9"'); ?>
			<?php echo form_error('description', '<div class="col-sm-12 no-padding red">', '</div>'); ?>
		</div>
	</div>
	<div>
		<?php 
    if(isset($images)):
      foreach($images->result_array() as $k => $row):
    ?>
      <label>
          <?php echo form_checkbox('delete[]', $row[field('id')],'', 'id="picture-'.($k + 1).'" onClick="checkFile('.($k + 1).')"'); ?> Remove<br>
          <img src="<?php echo IMAGE_ADS_SITE_PATH . 'thumbs/' . $row[field('name')]; ?>" alt="" />
      </label>
    <?php 
      endforeach;
    endif;
    ?>
  </div>
	<?php for($i = 1; $i <= MAX_ADS_IMAGE_UPLOAD; $i++): ?>
	<div class="space-4"></div>
	<div class="form-group">
		<label class="col-sm-3 control-label no-padding-right">Image <?php echo $i; ?></label>
		<div class="col-sm-9">
			<div class="ace-file-input<?php echo $i; ?> col-xs-10 col-sm-5 no-padding">
        <?php echo form_upload('image[]', '', 'id="input-file-image'.$i.'"'); ?>
			</div>
		</div>
	</div>
	<?php endfor; ?>
	<div class="clearfix form-actions">
		<div class="col-md-offset-3 col-md-9">
			<?php echo anchor(site_url(module_controller('view')),'&larr; Cancel', 'class="btn"');?>
			<button name="btnSave" class="btn btn-info" type="submit">
				<i class="icon-ok bigger-110"></i>Save
			</button>
		</div>
	</div>
<?php echo form_close();?>
